package bat.iog.test;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IpAddress {

    public static void main(String[] args) {
        try {
            InetAddress localhost = InetAddress.getLocalHost();
            String ipAddress = localhost.getHostAddress();

            if (!ipAddress.equals("127.0.0.1")) {
                System.out.println("本机IP地址: " + ipAddress);
            } else {
                System.out.println("本机IP地址不在 127.0.0.1 ");
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
